@extends('WShop::layout')
<style>
    .user_list {
        width: 100%;
        height: auto;
        overflow: hidden;
        background: #FFFFFF;
    }
</style>
@section('content')
    @include('WShop::public.header')
    <div style="height:60px;display: block"></div>
    <div class="user_list">
        <div style="line-height: 50px;text-align: center;padding-top: 10px;">
            <h2 style="width: 80%;padding-left: 18%;line-height: 25px;font-size: 18px;">{{$detail_info->title}}
                @if($type ==2)
                  <span style=" color:red ;font-size:14px;"> [@if($detail_info->type == 1)紧急@else普通@endif]</span>
                @endif
            </h2>
        </div>
        <div style="height:30px;line-height: 30px;text-align: center">
            发布时间: {{$detail_info->created_at}}
        </div>
        <div style="text-indent:2em;padding: 10px 20px;">
            @if($type ==1)<p style="text-align:center"><strong><span style="font-size:21px;font-family:宋体">{{$detail_info->subtitle}}</span></strong></p>@endif


{{--                @if($detail_info->cat_id==8)--}}
{{--                    <video style="width: 100%" src="{{$detail_info->mp4}}" controls="controls">--}}
{{--                        您的浏览器不支持--}}
{{--                    </video >--}}
{{--                @elseif($detail_info->cat_id==9)--}}
{{--                    <audio style="width: 100%" src="{{$detail_info->mp3}}" controls="controls">--}}
{{--                        您的浏览器不支持--}}
{{--                    </audio>--}}
{{--                @else--}}
                    <p style="text-align:center">
                    {!! $detail_info->content !!}
                    </p>
{{--                @endif--}}

            <p><br></p>
        </div>
{{--        <button type="button" id="qiandao" >获取积分</button>--}}
    </div>

    <div style="height:70px;display: block"></div>

    @include('WShop::public.foot_bar')
@endsection
@push('scripts')
    <script>
        var wait = 59;
        time();
        function time() {
            if (wait == 0) {
                $("#qiandao").removeAttr('disabled').removeClass('sc-text').addClass('sc-text-red');
                $("#qiandao").html("获取积分");
                wait = 59;
            } else {
                $("#qiandao").attr('disabled', 'disabled').removeClass('sc-text-red').addClass('sc-text');
                $("#qiandao").html( wait + "s后获取积分");
                wait--;
                setTimeout(function() {
                    time();
                },1000)
            }
        }
    </script>
    <script>
        var is_qiandao=0;

        $('#qiandao')[0].addEventListener('click',function(){
            if(is_qiandao==1){
                mui.toast('换篇文章再试吧');
                return false;
            }
            $.ajax({
                type: 'get',
                url: "{{route('f_Wap_User_qiandao')}}",
                dataType: 'json',
                data: ''
            }).done(function (response) {
                if(response.status){
                    tooltips(response.msg,6);
                    // setTimeout(function () {
                    //     location.href = response.url;
                    // }, 2000);
                }else{
                    tooltips(response.msg,5);
                }
            }).fail(function (XMLHttpRequest) {
                if (XMLHttpRequest.status == 422) {
                    var errors = XMLHttpRequest.responseJSON.errors;
                    if(typeof errors == 'object') {
                        for (var index in errors) { // 不推荐这样
                            tooltips(errors[index][0]);
                            break;
                        }
                    }else{
                        tooltips(XMLHttpRequest.responseJSON.msg);

                    }
                }else{
                    tooltips('网络异常,请检查连接');
                }

            }).always(function () {
                layer.close(load);
            });

            function tooltips(msg) {
                mui.toast(msg);
            }



            is_qiandao=1;
        })


    </script>

@endpush